package log

import (
	"fmt"
	"github.com/micro/go-micro/v2/logger"
	"github.com/natefinch/lumberjack"
	zap2 "go.uber.org/zap"
	zap "microprj/lib/log/zap"
	"time"
)

func InitZap()  {

	now := time.Now()
	hook := &lumberjack.Logger{
		Filename:   fmt.Sprintf("D:/gowsp/microprj/log/%04d%02d%02d%02d%02d%02d", now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second()),  //filePath
		MaxSize:    500, // megabytes
		MaxBackups: 10000,
		MaxAge:     100000, //days
		Compress:   false,  // disabled by default
	}

	l, err := zap.NewLogger(
		zap.WithCallerSkip(4),
		zap.WithConfig(zap2.NewProductionConfig()),
		zap.WithEncoderConfig(zap2.NewProductionEncoderConfig()),
		logger.WithOutput(hook),
	)
	if err != nil {

	}
	logger.DefaultLogger=l
}






